package com.school.manager.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.school.manager.domaim.SysUser;
import com.school.manager.entity.po.SysUserPo;
import com.school.manager.entity.vo.SysUserVo;
import com.school.manager.mapper.SysUserMapper;
import com.school.manager.service.ISysUserService;
import com.school.manager.utils.PageUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * description：系统用户业务实现类
 * date：2021/10/133:18 下午
 */

@Service
@Slf4j
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
	
	@Autowired
    private SysUserMapper sysUserMapper;
	
	@Override
	public Page<SysUserVo> page(SysUserPo sysUserPo) {
		QueryWrapper<SysUser> queryWrapper = PageUtil.buildQueryWrapper(sysUserPo, SysUser.class);
        Page<SysUser> page = new Page<>(sysUserPo.getCurrent(), sysUserPo.getSize());
        sysUserMapper.selectPage(page, queryWrapper);
        return PageUtil.buildPage(page, SysUserVo.class);
	}

	@Override
	public Page<SysUserVo> pageByClass(SysUserPo sysUserPo) {
    	Page<SysUserVo> page = new Page<>(sysUserPo.getCurrent(), sysUserPo.getSize());
    	List<SysUserVo> records = sysUserMapper.pageByClass(page, sysUserPo);
    	page.setRecords(records);
		return page;
	}

	@Override
	public Page<SysUserVo> pageNoClass(SysUserPo sysUserPo) {
		Page<SysUserVo> page = new Page<>(sysUserPo.getCurrent(), sysUserPo.getSize());
    	List<SysUserVo> records = sysUserMapper.pageNoClass(page, sysUserPo);
    	page.setRecords(records);
		return page;
	}
	
    
}
